package com.xai.pg;

import com.xai.pg.service.JPAGeneratorService;
import com.xai.pg.service.MyBatisGeneratorService;
import com.xai.pg.util.Conf;
import com.xai.pg.util.VMUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class ProGeneratorApplication {

    @Autowired
    private MyBatisGeneratorService mybatisService;
    @Autowired
    private JPAGeneratorService jpaService;

    @PostConstruct
    public void construct() {
        try {
            if (VMUtil.jpa) {
                jpaService.generator();
            } else {
                mybatisService.generator();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Conf.init();
        SpringApplication.run(ProGeneratorApplication.class, args);
    }
}
